"""
重写LoginRequiredMixin类
"""

from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import JsonResponse

class LoginRequiredJSONMixin(LoginRequiredMixin):

    def handle_no_permission(self):
        # 构建一个JsonResponse响应对象返回
        return JsonResponse({'code': 0, 'errmsg': '未登陆'}, status=401)